/**
 * @Author: LTT 17386012013@163.com
 * @Date: 2024-10-23 17:40:45
 * @Description:
 * @LastEditTime: 2024-10-24 16:42:11
 * @LastEditors: LTT 17386012013@163.com
 */
import { _decorator, Color, Component, Sprite, Node, UIOpacity } from "cc";
const { ccclass, property } = _decorator;

@ccclass("buttonClick")
export class buttonClick extends Component {
  @property
  originColor: Color = new Color(255, 255, 255, 255);
  @property
  targetColor: Color = new Color(128, 128, 128, 255);
  sprite: Sprite = null;
  ui: UIOpacity = null;
  protected onLoad(): void {
    this.sprite = this.node.getComponent(Sprite);
    this.ui = this.node.getComponent(UIOpacity);
    this.node.on(Node.EventType.TOUCH_START, () => {
      this.sprite.color = this.targetColor;
    });
    this.node.on(Node.EventType.TOUCH_END, () => {
      this.sprite.color = this.originColor;
    });
    this.node.on(Node.EventType.TOUCH_CANCEL, () => {
      this.sprite.color = this.originColor;
    });
  }
}
